import { useEffect, useState } from "react";

export const TryHookClosure = () => {
  let [num, setNum] = useState(1);
  const handClickAlert = () => {
    setTimeout(() => {
      alert(num);
    }, 1000);
  };

  return (
    <div className="">
      <button type="button" onClick={() => { setNum(num + 1) }}>点击{num}</button>
      <br />
      <button type="button" onClick={() => { handClickAlert() }}>alert</button>
    </div>
  );
}